<template>
  <div class="home">
    <!-- 面包屑 -->
    <mbx name1="订单管理" name2="订单列表" />
    <!-- card -->
    <el-card class="mt16">
      <el-input
        v-model="k"
        placeholder="请输入您想搜索的内容"
        style="width: 350px"
        @input="getlist"
      >
        <i class="el-icon-search" slot="append"></i>
      </el-input>
      <!-- 表格区 -->
      <el-table :data="orderlist" border style="width: 100%" class="mt16">
        <el-table-column fixed type="index" label="#"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格"> </el-table-column>
        <el-table-column label="是否付款">
          <template slot-scope="scope">
            <el-button
              type="danger"
              v-show="scope.row.pay_status == 0"
              size="mini"
              >未付款</el-button
            >
            <el-button
              type="success"
              v-show="scope.row.pay_status == 1"
              size="mini"
              >已付款</el-button
            >
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"> </el-table-column>
        <el-table-column label="下单时间">
          <template slot-scope="scope">
            {{ scope.row.create_time | gtimer }}
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              size="small"
              class="el-icon-edit"
              @click="dialogFormVisible1 = true"
            ></el-button>
            <el-button
              type="success"
              size="small"
              class="el-icon-location-outline"
              @click="dialogVisible = true"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="shuju.pagenum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="shuju.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
      <!-- 表格区 -->
      <!-- 物流进度 -->
      <el-dialog title="物流进度" :visible.sync="dialogVisible" width="40%">
        <el-timeline>
          <el-timeline-item
            v-for="(activity, index) in wul"
            :key="index"
            :icon="activity.icon"
            :color="activity.color"
            :timestamp="activity.time"
          >
            {{ activity.context }}
          </el-timeline-item>
        </el-timeline>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogVisible = false"
            >确 定</el-button
          >
        </span>
      </el-dialog>
      <!-- 物流进度 -->
      <!-- 编辑的模态框 -->
      <el-dialog
        title="修改地址"
        :visible.sync="dialogFormVisible1"
        width="40%"
      >
        <el-form :model="form1" ref="editadd" class="demo-ruleForm">
          <el-form-item label="省市区县">
            <el-cascader
              style="width: 280px"
              v-model="form1.arr"
              :options="city"
              :props="{
                expandTrigger: 'hover',
                value: 'value',
                label: 'label',
                children: 'children'
              }"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址">
            <el-input v-model="form1.name" style="width: 280px"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible1 = false">取 消</el-button>
          <el-button type="primary" @click="xg">确 定</el-button>
        </div>
      </el-dialog>
    </el-card>
    <!-- card -->
  </div>
</template>

<script>
import city from '@/city/city.js'
import wl from '@/wulist/wu.js'
export default {
  data() {
    return {
      wul: wl.data,
      city,
      orderlist: [],
      shuju: {
        query: '',
        pagenum: 1,
        pagesize: 6
      },
      k: '',
      total: 0,
      dialogVisible: false,
      activities: [],
      form1: {
        arr: [],
        name: ''
      },
      dialogFormVisible1: false
    }
  },
  mounted() {
    this.getlist()
  },
  methods: {
    //   渲染数据
    async getlist() {
      const res = await this.$API.getorder(this.shuju)
      console.log('订单数据', res)
      this.orderlist = res.goods
      this.total = res.total
    },
    //   分页
    handleSizeChange(val) {
      this.shuju.pagesize = val
      this.getlist()
    },
    handleCurrentChange(val) {
      this.shuju.pagenum = val
      this.getlist()
    },
    // 物流
    async wl(id) {
      console.log('物流id', id)
      this.dialogVisible = true
      const res = await this.$API.getorderwl(id)
      console.log('物流', res)
      this.activities = res
    },
    // 修改
    xg() {
      this.dialogFormVisible1 = false
      this.$message.success('修改成功哦')
      this.form1 = {
        arr: [],
        name: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.home {
  width: 100%;
}
// ::v-deep .el-input__inner {
//   width: 300px;
// }
</style>
